<?php
namespace App\Http\Controllers;
use App\Admin;
use DB;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class AdminController extends Controller
{	
	//注册
	public function reg(Request $request){
		if($request->input()){
			$username=$request->input('username');
			$salt="00544";
			$a=$request->input('password');
			$b=($a.$salt);
			$password=md5($b);
			$reg=new \App\Admin();
			$reg->reg($username,$password);
			if($reg){
				return view('admin/login');
			}
		}
		return view('admin.reg');
	}
	//登录
	public function login(Request $request){
		if($request->input()){
			$username=$request->input('username');
			$salt="00544";
			$a=$request->input('password');
			$b=($a.$salt);
			$password=md5($b);
			$log=new \App\Admin();
			$log->login($username,$password);
			if($log){
				return redirect('/msg/index');
			}
		}
		return view('admin.login');
	}
}